<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>录播推荐</title>
    #include("common/header.html")
    <link rel="stylesheet" href="/css/table.css"/>
</head>

<body>
<div class="admin-main">
    <fieldset class="layui-elem-field">
        <legend>直播推荐</legend>
        <div class="layui-field-box layui-form">
            <table class="layui-table admin-table">
                <thead>
                <tr>
                    <th>标题</th>
                    <th>直播人</th>
                    <th>观看人数</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody id="pager">
                #foreach($item in $data)
                <tr>
                    <td>$item.title</td>
                    <td>$item.name</td>
                    <td>$item.total</td>
                    <td>
                        <a onclick="edit($item.topId)" class="layui-btn layui-btn-danger layui-btn-mini">取消推荐</a>
                    </td>
                </tr>
                #end
                </tbody>
            </table>
        </div>
    </fieldset>
</div>
</body>

<script type="text/javascript">

    var layer;
    layui.use('layer', function () {
        layer = layui.layer;
    });

    function edit(id) {

        //询问框
        layer.confirm('确定取消当前直播间的推荐?', {
            btn: ['确定','取消'] //按钮
        }, function(){
            $.ajax({
                url: "/top/"+id,
                type: "delete",
                dataType: "json",
                success: function (r) {
                    console.log(r);

                    if(r.code == -1){
                        layer.msg(r.msg);
                        return;
                    }

                    layer.msg('操作成功!',{time:1000}, function(){
                        location.reload();
                    });
                }
            });
        });
    }

</script>

</html>